<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Elisa3: twimaster.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Elisa3
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('twimaster_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">twimaster.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="twimaster_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef _I2CMASTER_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define _I2CMASTER_H   1</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment">/************************************************************************* </span>
<a name="l00004"></a>00004 <span class="comment">* Title:    C include file for the I2C master interface </span>
<a name="l00005"></a>00005 <span class="comment">*           (i2cmaster.S or twimaster.c)</span>
<a name="l00006"></a>00006 <span class="comment">* Author:   Peter Fleury &lt;pfleury@gmx.ch&gt;  http://jump.to/fleury</span>
<a name="l00007"></a>00007 <span class="comment">* File:     $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $</span>
<a name="l00008"></a>00008 <span class="comment">* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3</span>
<a name="l00009"></a>00009 <span class="comment">* Target:   any AVR device</span>
<a name="l00010"></a>00010 <span class="comment">* Usage:    see Doxygen manual</span>
<a name="l00011"></a>00011 <span class="comment">**************************************************************************/</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#ifdef DOXYGEN</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span>
<a name="l00080"></a>00080 <span class="preprocessor">#endif </span><span class="comment">/* DOXYGEN */</span>
<a name="l00081"></a>00081 
<a name="l00084"></a>00084 <span class="preprocessor">#if (__GNUC__ * 100 + __GNUC_MINOR__) &lt; 304</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span><span class="preprocessor">#error &quot;This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !&quot;</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00087"></a>00087 <span class="preprocessor"></span>
<a name="l00088"></a>00088 <span class="preprocessor">#include &lt;avr/io.h&gt;</span>
<a name="l00089"></a>00089 
<a name="l00091"></a><a class="code" href="twimaster_8h.html#ab5c0fbe837494c5f9130a5914854250d">00091</a> <span class="preprocessor">#define I2C_READ    1</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span>
<a name="l00094"></a><a class="code" href="twimaster_8h.html#a9536bf85bced4f4e549a82fb18eb6140">00094</a> <span class="preprocessor">#define I2C_WRITE   0</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span>
<a name="l00096"></a>00096 
<a name="l00102"></a>00102 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="twimaster_8c.html#a5730d9445429351b9f750084c5cb5aae" title="initialize the I2C master interace. Need to be called only once">i2c_init</a>(<span class="keywordtype">void</span>);
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 
<a name="l00110"></a>00110 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="twimaster_8c.html#ad35d4e4f52ca74b503d5e5e1e0a3f5f3" title="Terminates the data transfer and releases the I2C bus.">i2c_stop</a>(<span class="keywordtype">void</span>);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 
<a name="l00120"></a>00120 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8c.html#aa3d328f00326115e9c660ccc838417c8" title="Issues a start condition and sends address and transfer direction.">i2c_start</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> addr);
<a name="l00121"></a>00121 
<a name="l00122"></a>00122 
<a name="l00130"></a>00130 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8c.html#a70c934b61f3c6ba8524104a1d7197d30" title="Issues a repeated start condition and sends address and transfer direction.">i2c_rep_start</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> addr);
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 
<a name="l00140"></a>00140 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="twimaster_8c.html#a0ef0de570e080339e04edb1176807560" title="Issues a start condition and sends address and transfer direction.">i2c_start_wait</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> addr);
<a name="l00141"></a>00141 
<a name="l00142"></a>00142  
<a name="l00149"></a>00149 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8c.html#add947aade44ed6b7f92265f9dec4a711" title="Send one byte to I2C device.">i2c_write</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data);
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 
<a name="l00156"></a>00156 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8c.html#a32ac22052d55f93375b024192217db21" title="read one byte from the I2C device, request more data from device">i2c_readAck</a>(<span class="keywordtype">void</span>);
<a name="l00157"></a>00157 
<a name="l00162"></a>00162 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8c.html#ad89e839fc17b05fbb5dd79897c55234e" title="read one byte from the I2C device, read is followed by a stop condition">i2c_readNak</a>(<span class="keywordtype">void</span>);
<a name="l00163"></a>00163 
<a name="l00173"></a>00173 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="twimaster_8h.html#ad33503cf741851d1bca1d274e9001796">i2c_read</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ack);
<a name="l00174"></a><a class="code" href="twimaster_8h.html#ad33503cf741851d1bca1d274e9001796">00174</a> <span class="preprocessor">#define i2c_read(ack)  (ack) ? i2c_readAck() : i2c_readNak(); </span>
<a name="l00175"></a>00175 <span class="preprocessor"></span>
<a name="l00176"></a>00176 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="twimaster_8c.html#a255e7886ed9ba7aa5509f7c6234d52fd">i2c_close</a>();
<a name="l00177"></a>00177 
<a name="l00179"></a>00179 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="twimaster_8h.html">twimaster.h</a>      </li>

    <li class="footer">Generated on Thu Dec 4 2014 08:30:47 for Elisa3 by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
